@extends('admin.layout.main')
@section('content')
    <div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
        <ul class="layui-tab-title site-demo-title">
            <li><a href="/admin/users">会员管理</a></li>
            <li class="layui-this">
                <a href="javascript:location.reload()">
                    角色管理
                </a>
            </li>
        </ul>
        <div class="layui-body layui-tab-content site-demo site-demo-body">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>
                    角色管理
                </legend>
            </fieldset>
            <form class="layui-form" action="/admin/users/{{$user->id}}/role" method="post" lay-filter="data-form">
                {{csrf_field()}}
                <div class="layui-form-item">
                    @foreach($roles as $role)
                        <div class="layui-input-block">
                            <input
                            type="checkbox"
                            name="roles[]"
                            lay-skin="primary"
                            title="{{$role->name}}"
                            value="{{$role->id}}"
                            @if ($myRoles->contains($role))
                                checked
                            @endif>
                        </div>
                    @endforeach
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="data-form">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
@endsection